#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import os
import time
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor


def tesk(res):
    time.sleep(1)
    print("{} hello {}".format(os.getpid(), res))


if __name__ == '__main__':
    pool = ProcessPoolExecutor(5)
    start = time.time()
    for i in range(1, 10):
        pool.submit(tesk, i)
    pool.shutdown(wait=True)  # 相当于是 p1.join()  等待子进程完成
    stop = time.time()
    print("主{} {}".format(os.getpid(), stop - start))  # 主24428 2.4276363849639893
